<template>
	<view>
		<view>
			<view v-for="defAddress in address">
				<view style="padding: 15px;border: 1px solid;" @click="chooseAddr(defAddress.id)">
					<h4>{{defAddress.address}}</h4>
					<view style="font-size: 14px;margin-top: 9px;">
						<text>{{defAddress.name}} </text>
						<text>{{defAddress.phone}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				address:[],
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			async getData(){
				let res = await this.$u.api.orderPre()
				this.address = res.address
			},
			//xuanzedizhi 
			chooseAddr(id){
				this.address.forEach(item=>{
					if(item.id===id){
						uni.setStorageSync('address', item);
					}
				})
				this.$u.route({
					url:'pages/cart/orderPre'
				})
			}
		},
	}
</script>

<style>

</style>
